﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using SDLITS.Common;
using SDLITS.Model;
using FineUI;
using MySoft.Data;


namespace SDLITS.Web.Basic
{
    public partial class AreaIF : CommonBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindTree();
                Region3.IFrameUrl = "RoomManage.aspx?aid=";
            }
        }

        private void BindTree()
        {
            List<Area> areall = SDDbSession.Default.From<Area>().ToList();
            foreach (Area row in areall)
            {
                int count = SDDbSession.Default.From<Room>().Where(Room._.AreaID == row.AreaID).Count();
                TreeNode node = new TreeNode();
                node.Text = row.AreaName + "(" + count + ")";
                node.Target = "main";
                node.NavigateUrl = "RoomManage.aspx?aid=" + row.AreaID;
                treeMenu.Nodes.Add(node);
            }
                        
            TreeNode n1 = new TreeNode();
            n1.Text = "全部区域房间";
            n1.Target = "main";
            n1.NavigateUrl = "RoomManage.aspx?aid=";
            treeMenu.Nodes.Insert(0, n1);
        }
    }
}